import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';

import {
    ArduinoTextBlocks,
    ArduinoTextGenerators,
    ArduinoVariablesBlocks,
    ArduinoVariablesGenerators,
    Variables,
    ArduinoProceduresBlocks,
    ArduinoProceduresGenerators,
    Procedures,
    Arduino
} from '@mixly/arduino';

import {
    ArduinoAVRActuatorBlocks,
    ArduinoAVRControlBlocks,
    ArduinoAVRFactoryBlocks,
    ArduinoAVRInoutBlocks,
    ArduinoAVRListsBlocks,
    ArduinoAVRLogicBlocks,
    ArduinoAVRMathBlocks,
    ArduinoAVRPinsBlocks,
    ArduinoAVRScoopBlocks,
    ArduinoAVRSerialBlocks,
    ArduinoAVRStorageBlocks,
    ArduinoAVRTextBlocks,
    ArduinoAVRToolsBlocks,
    ArduinoAVRActuatorGenerators,
    ArduinoAVRControlGenerators,
    ArduinoAVRFactoryGenerators,
    ArduinoAVRInoutGenerators,
    ArduinoAVRListsGenerators,
    ArduinoAVRLogicGenerators,
    ArduinoAVRMathGenerators,
    ArduinoAVRPinsGenerators,
    ArduinoAVRScoopGenerators,
    ArduinoAVRSerialGenerators,
    ArduinoAVRStorageGenerators,
    ArduinoAVRTextGenerators,
    ArduinoAVRToolsGenerators,
} from '@mixly/arduino-avr';

import pins from './pins/pins';
import * as CommunicateBlocks from './blocks/communicate';
import * as DisplayBlocks from './blocks/display';
import * as SensorBlocks from './blocks/sensor';
import * as ToolsBlocks from './blocks/tools';
import * as CommunicateGenerators from './generators/communicate';
import * as DisplayGenerators from './generators/display';
import * as SensorGenerators from './generators/sensor';
import * as ToolsGenerators from './generators/tools';

import './language/loader';

import './css/color.css';

Blockly.Arduino = Arduino;
Blockly.generator = Arduino;

Object.assign(Blockly.Variables, Variables);
Object.assign(Blockly.Procedures, Procedures);

Profile = Profile ?? {};
Profile.default = {};
Object.assign(Profile, pins);
Object.assign(Profile.default, pins.arduino_stm32f103c);

Object.assign(
    Blockly.Blocks,
    ArduinoTextBlocks,
    ArduinoVariablesBlocks,
    ArduinoProceduresBlocks,
    ArduinoAVRActuatorBlocks,
    ArduinoAVRControlBlocks,
    ArduinoAVRFactoryBlocks,
    ArduinoAVRInoutBlocks,
    ArduinoAVRListsBlocks,
    ArduinoAVRLogicBlocks,
    ArduinoAVRMathBlocks,
    ArduinoAVRPinsBlocks,
    ArduinoAVRScoopBlocks,
    ArduinoAVRSerialBlocks,
    ArduinoAVRStorageBlocks,
    ArduinoAVRTextBlocks,
    ArduinoAVRToolsBlocks,
    CommunicateBlocks,
    DisplayBlocks,
    SensorBlocks,
    ToolsBlocks
);

Object.assign(
    Blockly.Arduino.forBlock,
    ArduinoTextGenerators,
    ArduinoVariablesGenerators,
    ArduinoProceduresGenerators,
    ArduinoAVRActuatorGenerators,
    ArduinoAVRControlGenerators,
    ArduinoAVRFactoryGenerators,
    ArduinoAVRInoutGenerators,
    ArduinoAVRListsGenerators,
    ArduinoAVRLogicGenerators,
    ArduinoAVRMathGenerators,
    ArduinoAVRPinsGenerators,
    ArduinoAVRScoopGenerators,
    ArduinoAVRSerialGenerators,
    ArduinoAVRStorageGenerators,
    ArduinoAVRTextGenerators,
    ArduinoAVRToolsGenerators,
    CommunicateGenerators,
    DisplayGenerators,
    SensorGenerators,
    ToolsGenerators
);